#!/bin/sh

#  Copyright (C) 2014,2015,2018 Curt Brune <curt@cumulusnetworks.com>
#  Copyright (C) 2015 david_yang <david_yang@accton.com>
#
#  SPDX-License-Identifier:     GPL-2.0

# x86_64 boot mode implemenations see /etc/init.d/discover.sh

. /lib/onie/onie-blkdev-common

# We want rescue mode booting to be a one time operation.  After the
# rescue mode we should return to the default state.  On this
# architecture no action is necessary.
rescue_revert_default_arch()
{
    return 0
}

# Check whether we are running in NOS mode (after a successful NOS
# install) or not.  If we are running in NOS mode, then make
# architecture specific changes to turn the current install mode into
# a one time operation.
check_nos_mode_arch()
{
    local nos_mode="$(onie-nos-mode -g)"
    if [ "$nos_mode" = "yes" ] ; then
        # Clear the current boot mode to prevent install mode from
        # being sticky.
        onie-boot-mode -q -o none
        return 0
    fi

    # non-zero indicates NOS mode was not set
    return 1
}

# We want install mode booting to be sticky, e.g. if you boot into
# install mode you stay install mode until an installer runs
# successfully.
install_remain_sticky_arch()
{
    if [ "$(onie_get_running_firmware)" = "uefi" ] ; then
        uefi_boot_onie_install
    else
        bios_boot_onie_install
    fi
    sync;sync

    return 0
}

# Local Variables:
# mode: shell-script
# eval: (sh-set-shell "/bin/sh" t nil)
# End:
